package com.mmall.controller.portal;

import com.mmall.common.ServerResponse;
import com.mmall.service.IProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by root on 18-4-8.
 */
@Controller
@RequestMapping("/product/")
public class ProductController {

    private IProductService productService;

    @RequestMapping("detail.do")
    @ResponseBody
    public ServerResponse getProductDetail(Integer productId){
        return productService.getProductDetail(productId);
    }


    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse getProductList(Integer categoryId, String keyword,
                                         @RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum,
                                         @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
                                         @RequestParam(value = "orderBy", defaultValue = "")String orderBy){


        return  productService.searchProductList(categoryId, keyword, pageNum, pageSize, orderBy);
    }


}
